package topt_12z.statistics;

import java.util.LinkedList;
import java.util.Queue;

import topt_12z.network.PacketEvent;

public class SimulationStatistics {
	private static SimulationStatistics instance = null;

	private Queue<PacketEvent> receivedPacketsMap = new LinkedList<PacketEvent>();
	private int timeoutCounter = 0;
	private int notFinishedCounter = 0;
	private int lostBufferFull = 0;

	private SimulationStatistics() {
	}

	public static SimulationStatistics getInstance() {
		if (instance == null) {
			instance = new SimulationStatistics();
		}
		return instance;
	}
	
	public void reset() {
		instance = null;
	}

	public synchronized void addPacketToMap(PacketEvent event) {
		// log.finest("Entering");
		this.receivedPacketsMap.add(event);
	}

	public int getTimeoutCounter() {
		return timeoutCounter;
	}

	public void incrementTimeoutCounter() {
		this.timeoutCounter++;
	}
	
	public int getLostBufferFull() {
		return lostBufferFull;
	}

	public void incrementLostBufferFull() {
		this.lostBufferFull++;
	}

	public int getNotFinishedCounter() {
		return notFinishedCounter;
	}

	public void addToNotFinishedCounter(int addedValue) {
		this.notFinishedCounter += addedValue;
	}
	
	public int getReceivedPacketsCounter(){
		return receivedPacketsMap.size();
	}


}
